# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Eivind Uggedal <eu@eju.no>
# Maintainer:
pkgname=py3-nose
_pkgname=nose
pkgver=1.3.7
pkgrel=5
pkgdesc="Python3 unittest module"
url="http://readthedocs.org/docs/nose/"
arch="noarch"
license="LGPL-2.0-or-later"
depends="python3"
makedepends="py3-setuptools"
subpackages="$pkgname-doc"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
	coverage4-compat.patch
	python3.5-compat.patch
	fix-crashing-from-UnicodeDecodeError.patch
	fix-doctests-unicode.patch
	python3.6-compat.patch"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-nose" # Backwards compatiblity
provides="py-nose=$pkgver-r$pkgrel" # Backwards compatiblity

prepare() {
	default_prepare

	cd "$builddir"/examples
	cat attrib_plugin.py | tr -d '\r' > attrib_plugin.py.fixed
	mv attrib_plugin.py.fixed attrib_plugin.py
}

build() {
	python3 setup.py build
}

check() {
	(
		export PYTHONPATH="$(pwd)/build/lib"
		python3 setup.py build_tests
		python3 selftest.py
	)
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"

	# setup.py installs to "$pkgdir"/usr/man/man1
	install -D -m 644 nosetests.1 "$pkgdir"/usr/share/man/man1/nosetests.1
	rm -rf "$pkgdir"/usr/man
}

sha512sums="e65c914f621f8da06b9ab11a0ff2763d6e29b82ce2aaed56da0e3773dc899d9deb1f20015789d44c65a5dad7214520f5b659b3f8d7695fb207ad3f78e5cf1b62  nose-1.3.7.tar.gz
90238837b7d67a425c816e2160641aa55b8b0193d8b86c46efdd3d15b2d73880c8d6ad658bac40216bc9d8104de491bcec629cf7bfcf9f7a2022b7deec668f39  coverage4-compat.patch
68693cda7a9d5787f56a26bd98949817e67d8795c324c968cb8af599e1e5f190531f80fc71de1233b88918f21f558f4d81f92dde529f908a0a66e5dd80b7ec21  python3.5-compat.patch
741b97c6f8e33a8a712bb9db148cf869189065d0ea0c07b361356470b370a78e5075e6f631eb7fc714ace29c6904ee0324494b86cfe3414a6bb97193b5d77e52  fix-crashing-from-UnicodeDecodeError.patch
bcc01fb8283ea097739db5d52be6c1835cbc6f8a14a235f921d1b2b1d70ac0d91a039781e40dba55d5b5380aa963409223cf79a636fce756fe100a37e500503b  fix-doctests-unicode.patch
9c47a73a16766e77d086c1a0bb1cc59064eb5755c0d46bfd1814b1aa90dc90c672dda03547abff389f5a05633eff7a3991e41c5e61c12cf51080a08a71f79199  python3.6-compat.patch"
